using UnityEngine;
using System.Collections;

public class IntroCamera : MonoBehaviour {

	// Use this for initialization
	IEnumerator Start () {
		yield return new WaitForSeconds(3);
		StartCoroutine(Resize());
		StartCoroutine(Move());
		yield return new WaitForSeconds(2);
		Controller.inGame = true;
	}
	
	private IEnumerator Resize ()
	{
		while (Camera.main.orthographicSize < 10)
		{
			Camera.main.orthographicSize = Mathf.Lerp(Camera.main.orthographicSize, 10.2f, .6f * Time.deltaTime);
			yield return null;
		}
	}
	
	private IEnumerator Move ()
	{
		while (true)
		{
			Camera.main.transform.position = Vector3.Slerp(Camera.main.transform.position, new Vector3(0, 0, -10), 0.8f * Time.deltaTime);
			Camera.main.transform.rotation = Quaternion.Lerp(Camera.main.transform.rotation, Quaternion.identity, 0.8f * Time.deltaTime);
			yield return null;
		}
	}
	
	private IEnumerator DeathMove (Vector3 deathPos)
	{
		while(true)
		{
			Camera.main.transform.position = Vector3.Lerp(Camera.main.transform.position, deathPos + Vector3.forward * -4, 0.8f * Time.deltaTime);
			yield return null;
		}
	}
}
